
    ##########################################################################################
    ### R code for Figure 8 of Supplemental Material
    ##########################################################################################
 

    
    T <- 33  # number of congresses
    year.odd <- seq(from=1945, to=2010, by=2)
  
    Hou_Dat <- read.csv("Supplemental_Figure8_Data1.csv") # DW_NOM_Cutting_Line_Angles Data (House) from Voteview.com
    Sen_Dat <- read.csv("Supplemental_Figure8_Data2.csv") # DW_NOM_Cutting_Line_Angles Data (Senate) from Voteview.com
    
   
    CLA_FP_Hou <- matrix(NA, nrow=1, ncol=21)
    colnames(CLA_FP_Hou) <- names(Hou_Dat)
 
    CLA_FP_Sen <- matrix(NA, nrow=1, ncol=21)
    colnames(CLA_FP_Sen) <- names(Sen_Dat)
    
    # create the list of foreign policy votes used in my estimation: House
    ##############################################################################################   
    # Loop for 79 to 111th Houses.
      
    for(t in 79:111){
    Votes <- read.csv(paste("FP_All_H", t, ".csv", sep=""))
    original.label <- names(Votes)[6:ncol(Votes)]
    
    ### Decode the lable into vote list
    vote_list <- rep(NA, length(original.label))
    for(j in 1:length(original.label)){
    vote_list[j] <- as.numeric(strsplit(original.label, split="_v")[[j]][2])
    }
    
    ### Select out the votes from the file with cutting line angle
    Select1 <- subset(Hou_Dat, Congress==t)
    Select2 <- Select1[is.element(Select1$Vote_No, vote_list),]
    
    CLA_FP_Hou <- rbind(CLA_FP_Hou, Select2)
    }

    CLA_FP_Hou1 <- na.omit(CLA_FP_Hou[-1,])
    # Compute the average of |Angles|
    mean_abs_angles <- rep(NA, T)
    for(t in 79:111){
    mean_abs_angles[t-78] <- mean(abs(as.numeric(subset(CLA_FP_Hou1, Congress==t, select=c(Congress, Angle))$Angle)), na.rm=TRUE)
    }

    
    # create the list of foreign policy votes used in my estimation: Senate
    ##############################################################################################   
    # Loop for 79 to 111th Senate.
    for(t in 79:111){
    Votes <- read.table(paste("All_FP_votes_S", t, "th.txt", sep=""), header=T)
    original.label <- names(Votes)[6:ncol(Votes)]
    
    ### Decode the lable into vote list
    vote_list <- rep(NA, length(original.label))
    for(j in 1:length(original.label)){
    vote_list[j] <- as.numeric(strsplit(original.label, split="_v")[[j]][2])
    }
    
    ### Select out the votes from the file with cutting line angle
    Select1 <- subset(Sen_Dat, Congress==t)
    Select2 <- Select1[is.element(Select1$Vote_No, vote_list),]
    
    CLA_FP_Sen <- rbind(CLA_FP_Sen, Select2)
    }

    CLA_FP_Sen1 <- CLA_FP_Sen[-1,]
 
    mean_abs_angles_sen <- rep(NA, T) 
    for(t in 79:111){
    mean_abs_angles_sen[t-78] <- mean(abs(subset(CLA_FP_Sen1, Congress==t, select=c(Angle))), na.rm=TRUE)
    }
    


    postscript("Supplemental_Figure8.eps", height=6, width=8, horizontal=F)
    par(mfrow=c(1, 1))
    plot(1:T, mean_abs_angles, type='o', lty=1, col='blue', xaxt="n", xlab="", ylab="Mean of |Cutting Line Angles|", ylim=c(0, 90))
    points(1:T, mean_abs_angles_sen, type='o', lty=2)
    axis(side=1, las=3, at=1:T, labels=year.odd, cex.axis=.8)
    abline(h=45, lty=2)
    #title(main="The Numbers of Moderate Houators by Party",  font.main=1)
    legend('topleft', legend=c("House", "Senate"), lty=c(1, 2), col=c('blue', 'black'),cex=.8)
    dev.off()
